   {template 'header'}

<script src="../addons/bsht_tbk/res/js/main.js"></script>
<script src="../addons/bsht_tbk/res/js/nb_plus.js"></script>
<link rel="stylesheet" type="text/css" href="../addons/bsht_tbk/res/css/nb_plus.css" />
    
	<input type="hidden" id="key" name="key" x-webkit-speech="" value="{if $_GPC['keywords']}{$_GPC['keywords']}{/if}" />

    <div id="msv">
     <link rel="stylesheet" type="text/css" href="{$res}static/jwap/css/newpulic.css" />
    </div>
	
    <div id="goods">
     <section class="goods" id="pageCon">
      <ul class="goods-list list_box clear" id="list_box">
      </ul>
     </section>
	 <div id="list_more" class="loading" style="margin-top:10px"><span class="am-text-secondary" onclick="get_list(0);">查看更多</span></div>
     <!--div class="loading" id="loading" style="display: none;">
      <span>正在加载中，请稍后...</span>
     </div-->
    </div>
 
	
<script type="text/javascript">
$(document).ready(function(){ 

{if $setting['skin1tip']!=1}
//nb_plus
$(document).delegate(".new-coupon,.goodsget", "click", function () {
        var $this = $(this);
        var yhjid = $this.data("id");
		var nbpic = $this.data("bk");
        $.ajax({
            type: "post",
            url: "{php echo $this->createMobileUrl('yhj_tkl_nb_ajax', array('op' => 'nbpost'));}",
            dataType: "json",
            data: { id: yhjid },
            success: function (data) {
                if (data.code == 1000) {
                    popTao(nbpic, "淘口令", "对不起，优惠券已领空或产品已下架！");
                    //$(".taokaobox").html("<div class='popwcc'><a href='javascript:;' onclick='' class='popwcomfirm'>返回</a></div>");
                }
               else {
                    popTao(nbpic, "淘口令", "复制框内整段文字，打开【手机淘宝】即可【领取优惠券】并购买"+data.tkl);
                    {if $setting['isdd']==1}
					$(".taotip").html("预计奖励：" + data.yuji).show();
				    {/if}
                }
                selection();
                var hiturl = "{php echo $this->createMobileUrl('hit_ajax',array('act'=>'itemall'));}&id="+yhjid;		
                $.post(hiturl, function(dat){});
            }
        });
});
//nb_plus
{/if}


//var limit = {$tpage};
var tpyename = $('#tmptpye').val();
var minfee =  $('#minfee').val();
var maxfee =  $('#maxfee').val();
if(!typename){typename='moren';}
var limit = 1;
function get_list(ty){
    
    if(ty==1){
	   var keywords=$("input[name='key']").val();
	   if(keywords==""){
	      //dialog2("请输入要搜索的关键字！");
		  layer.msg('请输入关键字！');
		  //return false;
	   }
	   $("#pageCon .list_box").html('');
	}else{
	   $("#list_more").html('<div class="am-text-secondary"><span class="am-icon-spinner am-icon-spin"></span> 卖命加载中...</div>');
	   var keywords2=$("input[name='key']").val();
	   
	}
	
	$.ajax({
	    type : "post",
	    url : "{php echo $this->createMobileUrl('search_ajax')}",
	    data : {
	    	limit:limit,
			keywords:keywords,
			keywords2:keywords2,
			typename:typename,
			minfee:minfee,
			maxfee:maxfee,
	    },
        dataType : "json",		
	    success : function(data) {
	    	if(data.status==200){
						var list = data.content;
						var content = '';
						for(var i=0; i<list.length; i++){

                            

{if $setting['isdtk']==0}
//联盟                         
{if $setting['skin']==1 || empty($setting['skin'])}
  
content += '<li class="picCon"><a class="goods-a" href="'+list[i]['url']+'" target="_self">'
+'<img class="loazd lazy-bk" src="../addons/bsht_tbk/res/images/load.gif" data-bk="'+list[i]['pic']+'{$setting['maxpic']}.jpg" /></a>'
+'<a href="'+list[i]['url']+'" target="_self"><h3 class="tith3">'+list[i]['title']+'</h3>'
+'<div class="list-price buy"><span class="price-new"><i class="i-baoyou">包邮</i>'
+'<i class="i-quan">'+list[i]['toptag']+'</i></span></div><div class="list-price buy">'
+'<span class="price-new fs12">券后 '+list[i]['jiage']+'<i>元</i></span></div></a>'
+'<div class="b-btndiv"><div class="btn-l"><div class="btn-wai">'
+'<div class="btn-nei"><a href="'+list[i]['yhjurl']+'" class="abuy">领券</a></div></div></div>'
+'<div class="btn-l"><div class="btn-wai">'
+'<div class="btn-nei2"><a href="'+list[i]['url']+'" class="ashare">详情</a></div></div></div></div></li>';
		  
{else}    

         content += '<li class="picCon"><a class="goods-a" href="'+list[i]['url']+'" target="_self">'
		 +'<img class="loazd lazy-bk" src="../addons/bsht_tbk/res/images/load.gif" data-bk="'+list[i]['pic']+'{$setting['maxpic']}.jpg" /></a>'
		 +'<a href="'+list[i]['url']+'" target="_self">'
		 +'<h3>'+list[i]['title']+'</h3>'
         +'<div class="list-price buy">'
         +'<span class="price-new"><i>￥</i>'+list[i]['jiage']+'</span>'
         +'<span class="qhj" style="margin-left:5px">'+list[i]['tag']+'</span>'
         +'<!--a id="J_weixin" href="'+list[i]['yhjurl']+'" target="_self" class="coupon"><span class="good-btn">领券</span></a-->'
         +'</div></a>'
         +'<div class="lingquan">'
         +'<a id="J_weixin" href="'+list[i]['yhjurl']+'" target="_self" class="coupon"><span>'+list[i]['toptag']+'</span></a>'
         +'</div></li>';

{/if}
//联盟

{/if}
{if $setting['isdtk']==1}
//大淘客
{if $setting['skin']==1 || empty($setting['skin'])}
  
content += '<li class="picCon"><div style="float:left; width:16px; height:16px; background:url('+list[i]['icon']+'); margin-left:5px; margin-top:5px;position:absolute;z-index:10"></div><a class="goods-a" href="'+list[i]['url']+'" target="_self">'
+'<img class="loazd lazy-bk" src="../addons/bsht_tbk/res/images/load.gif" data-bk="'+list[i]['pic']+'{$setting['maxpic']}.jpg" /></a>'
+'<a href="'+list[i]['url']+'" target="_self"><h3 class="tith3">'+list[i]['title']+'</h3>'
+'<div class="list-price buy"><span class="price-new"><i class="i-baoyou">包邮</i>'
+'<i class="i-quan">内部券'+list[i]['jiage2']+'元</i></span></div><div class="list-price buy">'
+'<span class="price-new fs12"><span style="text-decoration: line-through;color: rgba(171, 171, 171, 1);">￥'+list[i]['itemfee']+'</span> 券后 '+list[i]['jiage']+'<i>元</i></span></div></a>'
+'<div class="b-btndiv"><div class="btn-l"><div class="btn-wai">'
+'<div class="btn-nei"><a href="'+list[i]['yhjurl']+'" class="abuy">领券</a></div></div></div>'
+'<div class="btn-l"><div class="btn-wai">'
+'<div class="btn-nei2"><a href="'+list[i]['url']+'" class="ashare">详情</a></div></div></div></div></li>';
		  
{else}    

         content += '<li class="picCon"><a class="goods-a" href="'+list[i]['url']+'" target="_self">'
		 +'<img class="loazd lazy-bk" src="../addons/bsht_tbk/res/images/load.gif" data-bk="'+list[i]['pic']+'{$setting['maxpic']}.jpg" /></a>'
		 +'<a href="'+list[i]['url']+'" target="_self">'
		 +'<h3>'+list[i]['title']+'</h3>'
         +'<div class="list-price buy">'
         +'<span class="price-new"><i>券后 ￥</i>'+list[i]['jiage']+'</span>'
         +'<!--span class="qhj" style="margin-left:5px">'+list[i]['tag']+'</span-->'
         +'<a id="J_weixin" href="'+list[i]['url']+'" target="_self" class="coupon"><span class="good-btn" style="color:#999">销量'+list[i]['itemmsell']+'</span></a>'
         +'</div></a>'
         +'<div class="lingquan">'
         +'<a id="J_weixin" href="'+list[i]['yhjurl']+'" target="_self" class="coupon"><span>'+list[i]['jiage2']+'元券</span></a>'
         +'</div></li>';

{/if}
//大淘客
{/if}




{if $setting['isdtk']==2}
//大淘客2
{if $setting['skin']==1 || empty($setting['skin'])}

var maxw = $('.app').width();
  
content += '<li class="picCon"><div style="float:left; width:16px; height:16px; background:url('+list[i]['icon']+'); margin-left:5px; margin-top:5px;position:absolute;z-index:10"></div><a class="goods-a new-coupon" name="'+list[i]['yhjurl2']+'&maxw='+maxw+'" class="abuy yhjurl2 new-coupon" id="'+list[i]['id']+'" data-id="'+list[i]['id']+'" data-bk="'+list[i]['pic']+'{$setting['maxpic']}.jpg" onclick="yhjjumpurl(this);">'
+'<img class="loazd lazy-bk" src="../addons/bsht_tbk/res/images/load.gif" data-bk="'+list[i]['pic']+'{$setting['maxpic']}.jpg" /></a>'
+'<a name="'+list[i]['yhjurl2']+'&maxw='+maxw+'" class="abuy yhjurl2 new-coupon" id="'+list[i]['id']+'" data-id="'+list[i]['id']+'" data-bk="'+list[i]['pic']+'{$setting['maxpic']}.jpg" onclick="yhjjumpurl(this);"><h3 class="tith3">'+list[i]['title']+'</h3>'
+'<div class="list-price buy"><span class="price-new"><i class="i-baoyou">包邮</i>'
+'<i class="i-quan">内部券'+list[i]['jiage2']+'元</i></span><span style="float:right;padding-right:10px;padding-top:2px;color:rgba(171, 171, 171, 1);font-size:12px">销量'+list[i]['itemmsell']+'</span></div><div class="list-price buy">'
+'<span class="price-new fs12"><span style="text-decoration: line-through;color: rgba(171, 171, 171, 1);">￥'+list[i]['itemfee']+'</span> 券后 '+list[i]['jiage']+'<i>元</i></span></div></a>'
+'<div class="b-btndiv"><div class="btn-l"><div class="btn-wai">'
+'<div class="btn-nei"><!--a href="'+list[i]['yhjurl']+'" class="abuy"--><a name="'+list[i]['yhjurl2']+'&maxw='+maxw+'" class="abuy yhjurl2 new-coupon" id="'+list[i]['id']+'" data-id="'+list[i]['id']+'" data-bk="'+list[i]['pic']+'{$setting['maxpic']}.jpg" onclick="yhjjumpurl(this);">领券</a></div></div></div>'
+'<div class="btn-l"><div class="btn-wai">'
+'<div class="btn-nei2"><a href="'+list[i]['url']+'" class="ashare">详情</a></div></div></div></div></li>';
		  
{else}

         content += '<li class="picCon"><a class="goods-a" href="'+list[i]['url']+'" target="_self">'
		 +'<img class="loazd lazy-bk" src="../addons/bsht_tbk/res/images/load.gif" data-bk="'+list[i]['pic']+'{$setting['maxpic']}.jpg" /></a>'
		 +'<a href="'+list[i]['url']+'" target="_self">'
		 +'<h3>'+list[i]['title']+'</h3>'
         +'<div class="list-price buy">'
         +'<span class="price-new"><i>券后 ￥</i>'+list[i]['jiage']+'</span>'
         +'<!--span class="qhj" style="margin-left:5px">'+list[i]['tag']+'</span-->'
         +'<a id="J_weixin" href="'+list[i]['url']+'" target="_self" class="coupon"><span class="good-btn" style="color:#999">销量'+list[i]['itemmsell']+'</span></a>'
         +'</div></a>'
         +'<div class="lingquan">'
         +'<a id="J_weixin" href="'+list[i]['yhjurl']+'" target="_self" class="coupon"><span>'+list[i]['jiage2']+'元券</span></a>'
         +'</div></li>';

{/if}
//大淘客2
{/if}




						}
                        $("#pageCon .list_box").append(content);
						var aa = $(".goods-list li").innerWidth();
                        $(".goods-list li img").css('height',aa);
						if(list.length=={if $setting['pageno']}{$setting['pageno']}{else}10{/if}){
							$("#list_more").html('<span class="am-text-secondary" onclick="get_list(0);">点击查看更多</span>');
						}else{
							$("#list_more").html('<span></span>');
							$("#list_more").fadeOut(500);
						}		
	                    limit++;

						

//waterfall();
lazy_img();

		    }else if(data.status==-103){
	    		$("#list_more").html('<span>没有更多记录！</span>');
				$("#list_more").fadeOut(500);
				location.reload();

	    	}else if(data.status==301){
	    		$("#list_more").html('<span>没有搜索到内容！</span>');
				$("#list_more").fadeOut(500);
				
	    	}else{
			    $("#list_more").html('<span>没有更多记录！</span>');
				$("#list_more").fadeOut(500);
			}    	
	    },
	    error : function(xhr, type) {

	    }
	});
	    

}


get_list(1);


$(".xl_div_002").off("click").on("click",function(){
       $("#pageCon .list_box").html('');
	   typename =  $(this).attr("data-id");
	   $('#tmptpye').val(typename);
	   typetxt =  $(this).html();
	   $('#dc_xl_002').html(typetxt);
	   $('#xl_002').css("height","0px");
	   sq_xl();
	   limit = 1;
	   get_list(0);

	   //alert(typename);
});


$(".xl_div_006_3").off("click").on("click",function(){
       $("#pageCon .list_box").html('');
	   minfee =  $('#minfee').val();
	   maxfee =  $('#maxfee').val();
	   $('#xl_002').css("height","0px");
	   sq_xl();
	   limit = 1;
	   get_list(0);

	   //alert(typename);
});

//==============自动加载=============
{if $setting['autoclick']!=0}
//获取滚动条当前的位置 
function getScrollTop() { 
var scrollTop = 0; 
if (document.documentElement && document.documentElement.scrollTop) { 
scrollTop = document.documentElement.scrollTop; 
} 
else if (document.body) { 
scrollTop = document.body.scrollTop; 
} 
return scrollTop; 
} 

//获取当前可是范围的高度 
function getClientHeight() { 
var clientHeight = 0; 
if (document.body.clientHeight && document.documentElement.clientHeight) { 
clientHeight = Math.min(document.body.clientHeight, document.documentElement.clientHeight); 
} 
else { 
clientHeight = Math.max(document.body.clientHeight, document.documentElement.clientHeight); 
} 
return clientHeight; 
} 

//获取文档完整的高度 
function getScrollHeight() { 
return Math.max(document.body.scrollHeight, document.documentElement.scrollHeight); 
} 


$(window).scroll(function () { 
if (getScrollTop() + getClientHeight() == getScrollHeight()) { 
//alert("到达底部"); 
get_list(0);
} 
});

{/if}
//==============自动加载=============  

function waterfall(limit){
$container = $('#list_box');
$container.masonry('reload');
	$container.imagesLoaded(function() {
		lazy_img();
		$container.masonry({
			itemSelector: '.picCon',
			isFitWidth: false,//是否根据浏览器窗口大小自动适应默认false
			//gutter: 20,
			isAnimated: false,//是否采用jquery动画进行重拍版
			isRTL:false,//设置布局的排列方式，即：定位砖块时，是从左向右排列还是从右向左排列。默认值为false，即从左向右
            isResizable: true,//是否自动布局默认true
			});
		});
}


}); 

function yhjjumpurl(obj){
{if $setting['skin1tip']==1} 
 var url = obj.name;
 //alert(url);
 layer.open({
  type: 2,
  title: false,
  shadeClose: true,
  shade: 0.8,
  area: ['85%', '85%'],
  content: url
}); 
{/if}
}
</script>

	{template 'footer'}